<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Adding an exercise to ${routine.name }</title>
</head>
<script>
    var choices = ${exercises};
    function ddchange(dd1) {
        // Fill dd2 options based on selected dd1 value.
        var selected = dd1.options[dd1.selectedIndex].text;
        var box = document.getElementById("dd2");
        var box2 = document.getElementById("dd3");
        
        for(var count = box.options.length - 1; count >= 0; count--)
    	{
        box.options[count] = null;
    	}
        for (var item in choices[selected]){
        
	        var option = document.createElement("OPTION");
	        option.text = item;
	        option.value = choices[selected][item];
        	box.options.add(option);
        }
       

    	document.writeln(vars);
    	document.close();
      //  for (var item in vars}){
     //   	var option = document.createElement("OPTION");
	     //   option.text = item;
	    //    option.value = item;
        //	box2.options.add(option);
      //  }
    }
    
        function varchange(dd1) {
        // Fill dd2 options based on selected dd1 value.
        var selected = dd1.options[dd1.selectedIndex].text;
        var box = document.getElementById("dd2");
        
 
        

    }
    
    function validate(form)	{
		form.submit();

	}
</script>

<body>
<jsp:include page="/includes/nav.jsp"/>
<form action="addentry?id=${routine.id }" method="post">
<table>
	<tr>
		<td>Choose a muscle group</td>
		<td><select name="dd1" onchange="ddchange(this)">
		<option>---</option>
			<c:forEach items="${groupsarray}" var="option">
				<option value="${option.key}"> ${option.key}</option>
			</c:forEach>
		</select></td>
	</tr>
	<tr>
		<td>Select an exercise</td>
		<td><select name="exer" id="dd2">
		</select></td>
	</tr>
	<tr>
		<td>Select a variation</td>
			<c:forEach items="${variations}" var="option">
				<td><input type="checkbox" name="variation" value="${option.key}"/>${option.value}</td></tr><tr><td><br>
			</c:forEach></td>
	</tr>
	<tr>
		<td>Select the order placement</td>
		<td><input type="text" name="order" size=3></td>
		<td>Use identical orders to provide alternative exercises</td>
	</tr>
	<tr>
		<td>Suggested Sets:</td>
		<td><input type="text" name="sets" size=3></td>
	</tr>
	<tr>
		<td>Suggested Reps:</td>
		<td><input type="text" name="reps" size=3></td>
		<td>Complicated rep structure? Describe it in the notes below</td>
	</tr>
	<tr>
		<td>Note:</td>
		<td colspan=2><textarea rows="3" cols="25" name="notes">Enter specific rest or rep instructions here</textarea></td>
	</tr>
	<tr>
		<td><input type="button" value="Submit"
			onClick="validate(this.form)"></td>
		<td><input type="hidden" name="id" value="${routine.id }"></td>
	</tr>
</table>
</form>
~~~List of current routine entries goes here to show what you have so
far.
</body>
</html>